﻿/* Filename: SHA1Hash.cs
 * Author: Vo Manh Cuong
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;

namespace VMCCryptoLib.HashEncryption
{
    public class SHA1Hash
    {
		#region --- Public Methods
		/// <summary>
		/// Method to hash a string with SHA1 algorithm
		/// </summary>
		/// <param name="inputData">string to hash</param>
		/// <returns>string hashed</returns>
		public static string ThisString(string inputData)
		{
			string result = string.Empty;
			if(inputData!=null || inputData.Length!=0)
			{
				try
				{
					SHA1 crypto = SHA1.Create();
					byte[] hash = crypto.ComputeHash(Encoding.ASCII.GetBytes(inputData));
					StringBuilder strBuilder = new StringBuilder();
					foreach(byte b in hash)
					{
						strBuilder.AppendFormat("0{:x2}",b);
					}
					result = strBuilder.ToString();
				}
				catch(Exception ex)
				{
					result = string.Empty;
					throw new Exception(ex.Message);
				}
			}
			else
			{
				result = string.Empty;	
			}
			return result;
		}
		
		public static bool ThisFile(string fileName)
		{
			bool rs = false;
			return rs;
		}
		#endregion
    }
}
